package imv3.foo.server.handler;

import imv3.protocol.request.HeartBeatRequestPacket;
import imv3.protocol.response.HeartBeatResponsePacket;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author @xsomnus666_xiawenye★
 * @since 2019/4/26 0026 14:12
 * 当你发现自己的才华撑不起野心时，就请安静下来学习吧
 */
@ChannelHandler.Sharable
public class HeartBeatRequestHandler extends SimpleChannelInboundHandler<HeartBeatRequestPacket> {

    public static final HeartBeatRequestHandler INSTANCE = new HeartBeatRequestHandler();

    public HeartBeatRequestHandler() {
    }

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, HeartBeatRequestPacket msg) throws Exception {
        System.out.println("收到客户端[" + ctx.channel() + "]的心跳信息");
        ctx.writeAndFlush(new HeartBeatResponsePacket());
    }
}
